<template>
  <div class="specCard">
    <div class="cardTop jscenter">
      <p class="name">{{ options?.name ? options?.name : "规格名称" }}</p>
      <nut-image
        @click="editSpecCard"
        class="editIcon"
        :src="getAssetsFile('specSet/editIcon.png')"
      ></nut-image>
      <p class="delete" @click="deleteSpecCard" v-if="!options?.isNew">删除</p>
    </div>
    <div class="cardCenter">
      <template v-if="options?.specs?.length > 0">
        <div class="cardItem ccenter" v-for="item in options?.specs">
          <p class="lable">{{ item.spec_value }}</p>
          <nut-image
            @click="deleteChild(options, item)"
            class="editIcon"
            :src="getAssetsFile('specSet/closeIcon.png')"
          ></nut-image></div
      ></template>
    </div>
    <div class="cardBottom ccenter" @click="addSpecCard">+添加具体规格</div>
  </div>
</template>

<script setup lang="ts">
import { getAssetsFile } from "@/utils/pub-use";
const props = defineProps<{ options?: any }>();
const emits = defineEmits(["delete", "add", "edit", "deleteChild"]);

const addSpecCard = () => {
  emits("add");
};
const deleteSpecCard = () => {
  emits("delete");
};
const editSpecCard = () => {
  emits("edit");
};

const deleteChild = (options: any, item: any) => {
  emits("deleteChild", options, item);
};
</script>

<style lang="scss" scoped>
.specCard {
  padding: 20px;
  background: #ffffff;
  border-radius: 20px;
  .cardTop {
    .name {
      font-weight: 500;
      color: #000000;
      font-size: 30px;
    }
    .editIcon {
      width: 29px;
      height: 29px;
      margin-left: 20px;
      margin-right: auto;
    }
    .delete {
      color: #999999;
      font-size: 28px;
    }
  }
  .cardCenter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 10px;
    .cardItem {
      min-width: 127px;
      background: #f8f9fa;
      border-radius: 27px;
      margin-top: 20px;
      padding: 9px 25px;
      margin-right: 20px;
      .lable {
        color: #000000;
        font-size: 26px;
        margin-right: 27px;
      }
      .editIcon {
        width: 19px;
        height: 18px;
      }
    }
  }
  .cardBottom {
    margin-top: 20px;
    width: 221px;
    height: 55px;
    background: #f8f9fa;
    border-radius: 27px;
    color: #26acf5;
    font-size: 26px;
  }
}
</style>
